﻿/*堆叠条形图*/
function ColumnStackedLineChart(colSCharto) {
    this.colSChartDom = colSCharto.dom;
    this.quotatitle = colSCharto.title ? colSCharto.title : " ";
    this.quotatitleD = colSCharto.quotatitleD ? colSCharto.quotatitleD : "";
    this.quotatitleDClass = colSCharto.quotatitleDClass ? colSCharto.quotatitleDClass : "";
    this.xData = colSCharto.xData;
    this.yData = colSCharto.yData;
    this.unit = colSCharto.unit ? colSCharto.unit : "件";
    this.maxData = colSCharto.maxData;
    var self = this;
    var isstringEmpty = self.quotatitleDClass == "" ? false : true;
    return new Highcharts.Chart({
        chart: {
            renderTo: self.colSChartDom,
            type: 'bar',
            showAxes: false
        },
        title:{
           text:null,
        },
        xAxis: [{
            categories: self.xData,
            reversed:false,
            labels:{ step:1 },
            title:{
                text:'单位：(年)',
                align:'high',
                offset: 0,
                rotation:0,
                y:-10,
                x:20
            }
        },{
            opposite:true,
            reversed:false,
            categories:self.xData,
            linkedTo:0,
            labels:{ step:1 },
            title:{
                text:'单位：(年)',
                align:'high',
                offset: 0,
                rotation:0,
                y:-10,
                x:20
            }
        }],
        yAxis: {
            gridLineWidth: 0,
            lineWidth: 1,
            title: {
                text:'单位：(件)',
            },
            stackLabels: {
                enabled: true,
                formatter:function(){
                    return Math.abs(this.total);
                },
                style: {
                    color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
                }
            },
            labels: {
                formatter: function () {
                    return Math.abs(this.value);
                }
            },
            min:-self.maxData,
            max:self.maxData,
        },
        credits: {
            enabled: false
        },
        legend: {
            reversed:false,
            verticalAlign: 'top'
        },
        colors: ['#FAD77B','#6B9FCF'],
        tooltip: {
            borderColor: '#cacaca',
            borderWidth: 1,
            formatter: function (i) {
                return '<b>' + this.x + '</b><br/>' +
                            this.series.name + ': ' +  Math.abs(this.y) + '<br/>';
            }
        },
        plotOptions: {
            series:{
                stacking:'normal',
            },
            column:{
                borderWidth:0,
                pointWidth:80,
                dataLabels: {
                    enabled: true,
                    color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'black'
                }
            }
        },
        series: self.yData
    });
}